package com.nanfang51g3.ckz.ui.fragment.fill;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.nanfang51g3.ckz.R;
import com.nanfang51g3.ckz.ui.money.fill.FillInContract;
import com.nanfang51g3.ckz.ui.money.preview.PreviewMoneyInfoActivity;
import com.nanfang51g3.ckz.utils.KLog;
import com.nanfang51g3.ckz.utils.SPUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/4/28.
 */
public class FillInAliPayFragment extends Fragment {
    public static FillInContract.FillInActionsListener mFillInActionsListener;

    @Bind(R.id.tv_fill_in_ali_pay_withdraw_id)
    TextView tvFillInAliPayWithdrawId;
    String ali_pay;
    @Bind(R.id.relative_fill_in_ali_pay)
    RelativeLayout relativeFillInAliPay;

    public static FillInAliPayFragment newInstance(Context context, FillInContract.FillInActionsListener fillInActionsListener) {
        FillInAliPayFragment fillInAliPayFragment = new FillInAliPayFragment();
        Bundle args = new Bundle();
        String ali_pay_ = (String) SPUtil.get(context, "ali_pay_card", "暂未填写");
        KLog.i("Evd", "ali_pay_card=" + ali_pay_);
        args.putString("ali_pay_card", ali_pay_);
        fillInAliPayFragment.setArguments(args);
        mFillInActionsListener = fillInActionsListener;
        KLog.i("Evd", fillInActionsListener == null ? "fillInActionsListener - 1" : "fillInActionsListener - 0");
        return fillInAliPayFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fill_in_ali_pay_fragment, null);
        ButterKnife.bind(this, view);
        Bundle bundle = getArguments();
        ali_pay = bundle.getString("ali_pay_card");
        KLog.i("Evd", "alipay_=" + ali_pay);
        tvFillInAliPayWithdrawId.setText(ali_pay);


        return view;
    }

    @Override
    public void onResume() {
        super.onResume();
        KLog.i("Evd","onResume");
        String ali_pay_ = (String) SPUtil.get(getActivity(), "ali_pay_card", "暂未填写");
        tvFillInAliPayWithdrawId.setText(ali_pay);
    }

    @OnClick(R.id.relative_fill_in_ali_pay)
    public void relative_fill_in_ali_pay(View view) {
        startActivity(new Intent(getActivity(), PreviewMoneyInfoActivity.class));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);

    }
}
